import { resultPageSuccess, resultSuccess } from "mock/_util";
import { MockMethod } from "vite-plugin-mock";
import { getScore } from "./data";

function getTeachingRecordList() {
  const list: any[] = [];
  for (let i = 0; i < 30; i++) {
    list.push({
      recordId: i,
      lessonDate: "2012-10-16",
      place: `教室${i}`,
      ...getScore(),
    });
  }
  return list;
}

export default [
  {
    url: "/dev-api/teachingRecord/page",
    timeout: 100,
    method: "get",
    response: ({ query }) => {
      const { pageNum = 1, pageSize = 10 } = query;
      return resultPageSuccess(pageNum, pageSize, getTeachingRecordList());
    },
  },
  {
    url: "/dev-api/teachingRecord/page/:userId",
    timeout: 100,
    method: "get",
    response: ({ query }) => {
      const { pageNum = 1, pageSize = 10 } = query;
      return resultPageSuccess(pageNum, pageSize, getTeachingRecordList());
    },
  },
  {
    url: "/dev-api/teachingRecord/getScore/:userId/:planId",
    timeout: 100,
    method: "get",
    response: () => {
      return resultSuccess(getScore());
    },
  },
  {
    url: "/dev-api/teacherRecord/setScore/:userId/:planId",
    timeout: 100,
    method: "put",
    response: () => {
      return resultSuccess({});
    },
  },
] as MockMethod[];
